//
//  WeaherHeaderView.m
//  WeatherOFChangsha
//
//  Created by zkingsoft on 15/12/16.
//  Copyright (c) 2015年 zkingsoft. All rights reserved.
//

#import "WeaherHeaderView.h"

@implementation WeaherHeaderView

- (instancetype)init{
    self = [super init];
    if (self) {
        self.backgroundColor = [UIColor clearColor];
        self.cityNameLabel = [[UILabel alloc] init];
        self.cityTempLabel = [[UILabel alloc] init];
        self.cityWeekLabel = [[UILabel alloc] init];
        self.cityPM25Label = [[UILabel alloc] init];
        
        self.cityNameLabel.textAlignment = NSTextAlignmentCenter;
        self.cityNameLabel.textColor = [UIColor whiteColor];
        self.cityNameLabel.font = [UIFont systemFontOfSize:26 weight:2];
        self.cityNameLabel.text = @"城市名称";
        
        self.cityTempLabel.textAlignment = NSTextAlignmentCenter;
        self.cityTempLabel.textColor = [UIColor whiteColor];
        self.cityTempLabel.font = [UIFont systemFontOfSize:37 weight:2];
        self.cityTempLabel.text = @"城市气温";
        
        self.cityWeekLabel.textAlignment = NSTextAlignmentLeft;
        self.cityWeekLabel.textColor = [UIColor whiteColor];
        self.cityWeekLabel.text = @"周几";
        
        self.cityPM25Label.textAlignment = NSTextAlignmentRight;
        self.cityPM25Label.textColor = [UIColor whiteColor];
        self.cityPM25Label.text = @"PM25";
        
        [self addSubview:self.cityNameLabel];
        [self addSubview:self.cityTempLabel];
        [self addSubview:self.cityPM25Label];
        [self addSubview:self.cityWeekLabel];
        
        [self.cityNameLabel makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.top).offset(32);
            make.left.equalTo(self.left).offset(16);
            make.right.equalTo(self.right).offset(-16);
            make.height.equalTo(30);
        }];
        
        [self.cityTempLabel makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.cityNameLabel.bottom).offset(16);
            make.left.equalTo(self.left).offset(16);
            make.right.equalTo(self.right).offset(-16);
            make.height.equalTo(35);
        }];
        
        [self.cityWeekLabel makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.left).offset(8);
            make.right.equalTo(self.centerX);
            make.bottom.equalTo(self.bottom);
            make.height.equalTo(21);
        }];
        
        [self.cityPM25Label makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.centerX);
            make.right.equalTo(self.right).offset(-8);
            make.bottom.equalTo(self.bottom);
            make.height.equalTo(21);
        }];
        
        
        // 选择城市按钮
        self.chioceCityButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [self.chioceCityButton setTitle:@"选择城市" forState:UIControlStateNormal];
        [self.chioceCityButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [self addSubview:self.chioceCityButton];
        [self.chioceCityButton makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.left).offset(6);
            make.top.equalTo(self.top).offset(26);
            make.width.equalTo(80);
            make.height.equalTo(44);
        }];
    }
    return self;
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
